<?php
namespace Adminx\Controller;

class OneController extends AdminController {

	#列表
	public function index() {
		$obj = M('Onepage');
		$count = $obj->count();
		import("Common.ORG.Page");
		$page = new \Page($count, 15);
		$show = $page->show();
		$list = $obj->order('id asc')->limit($page->firstRow . ',' . $page->listRows)->select();
		$this->assign('list', $list);
		$this->assign('page', $show);
		$this->display();
	}

	#添加
	public function add() {
		if($_POST){
			$this->all_add('Onepage',U('One/index'));
		}else{
			$this->display();
		}
	}

	#编辑
	public function edit() {
		if($_POST){
			$this->all_save('Onepage',U('One/index'));
		}else{
			$id = I('get.id');
			if ($id=='' || !is_numeric($id)) {
				$this->error('参数错误');
			}
			$obj = M('Onepage');
			$map['id'] = $id;
			$list = $obj->where($map)->find();
			if (!$list) {
				$this->error('信息不存在');
			} else {
				$this->assign('list', $list);
				$this->display();
			}
		}
	}

	#删除
	public function del() {
		$this->all_del('Onepage','reload');
	}
}
?>